/**
 * 
 */
package com.yidu.drug.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.drug.common.Page;
import com.yidu.drug.common.Tools;
import com.yidu.drug.dao.ProductionEnterpriseModelMapper;
import com.yidu.drug.model.ProductionEnterpriseModel;
import com.yidu.drug.service.PreService;

/**
 * 生产地址的Service实现类
 * @author 王志伟
 * @date 2018年8月28日 上午8:38:11
 * @version 1.0
 */
@Service
public class PreServiceImpl implements PreService{
	
	//生产地址的DAO
	@Resource
	private ProductionEnterpriseModelMapper preDao;

	@Override
	public int deleteByPrimaryKey(String preId) {
		// TODO Auto-generated method stub
		return preDao.deleteByPrimaryKey(preId);
	}

	@Override
	public int insert(ProductionEnterpriseModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(ProductionEnterpriseModel record) {
		record.setPreId(Tools.getRandomUUID());
		record.setIsva(Tools.ISVA_YES);
		int count=preDao.insertSelective(record);
		return count;
	}

	@Override
	public ProductionEnterpriseModel selectByPrimaryKey(String preId) {
		// TODO Auto-generated method stub
		return preDao.selectByPrimaryKey(preId);
	}

	@Override
	public int updateByPrimaryKeySelective(ProductionEnterpriseModel record) {
		// TODO Auto-generated method stub
		return preDao.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(ProductionEnterpriseModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object> findAll(String limit, String page, String preSite) {
		//NEW一个生产的模型,加入页面信息和企业名称
		ProductionEnterpriseModel preModel = new ProductionEnterpriseModel();
		Page pa=new Page();
		pa.setPage(Integer.valueOf(page));
		pa.setRows(Integer.valueOf(limit));
		preModel.setPage(pa);
		preModel.setPreSite(preSite);
		//查询所有信息或者按条件查询
		List<ProductionEnterpriseModel> list=preDao.findAll(preModel);
		//查询出的信息的总行数
		Long count = preDao.findRows(preModel);
		System.out.println("总行数"+count);
		//加入MAP集合
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code",0);
		map.put("msg","");
		map.put("count",count);
		map.put("data", list);
		return map;
	}

	@Override
	public List<ProductionEnterpriseModel> findAlls() {
		List<ProductionEnterpriseModel> list=preDao.findAlls();
		for (ProductionEnterpriseModel productionEnterpriseModel : list) {
			System.out.println("地址+"+productionEnterpriseModel.getPreSite());
		}
		return list;
	}
	
	
}
